use core::fmt;

#[derive(Copy, Clone, PartialEq, Eq, FromPrimitive, ToPrimitive)]
pub enum ElfMachine {
    EM_NONE = 0,
    EM_M32 = 1,
    EM_SPARC = 2,
    EM_386 = 3,
    EM_68K = 4,
    EM_88K = 5,
    EM_IAMCU = 6,
    EM_860 = 7,
    EM_MIPS = 8,
    EM_S370 = 9,
    EM_MIPS_RS3_LE = 10,
    EM_PARISC = 15,
    reserved = 16,
    EM_VPP500 = 17,
    EM_SPARC32PLUS = 18,
    EM_960 = 19,
    EM_PPC = 20,
    EM_PPC64 = 21,
    EM_S390 = 22,
    EM_SPU = 23,
    EM_V800 = 36,
    EM_FR20 = 37,
    EM_RH32 = 38,
    EM_RCE = 39,
    EM_ARM = 40,
    EM_ALPHA = 41,
    EM_SH = 42,
    EM_SPARCV9 = 43,
    EM_TRICORE = 44,
    EM_ARC = 45,
    EM_H8_300 = 46,
    EM_H8_300H = 47,
    EM_H8S = 48,
    EM_H8_500 = 49,
    EM_IA_64 = 50,
    EM_MIPS_X = 51,
    EM_COLDFIRE = 52,
    EM_68HC12 = 53,
    EM_MMA = 54,
    EM_PCP = 55,
    EM_NCPU = 56,
    EM_NDR1 = 57,
    EM_STARCORE = 58,
    EM_ME16 = 59,
    EM_ST100 = 60,
    EM_TINYJ = 61,
    EM_X86_64 = 62,
    EM_PDSP = 63,
    EM_PDP10 = 64,
    EM_PDP11 = 65,
    EM_FX66 = 66,
    EM_ST9PLUS = 67,
    EM_ST7 = 68,
    EM_68HC16 = 69,
    EM_68HC11 = 70,
    EM_68HC08 = 71,
    EM_68HC05 = 72,
    EM_SVX = 73,
    EM_ST19 = 74,
    EM_VAX = 75,
    EM_CRIS = 76,
    EM_JAVELIN = 77,
    EM_FIREPATH = 78,
    EM_ZSP = 79,
    EM_MMIX = 80,
    EM_HUANY = 81,
    EM_PRISM = 82,
    EM_AVR = 83,
    EM_FR30 = 84,
    EM_D10V = 85,
    EM_D30V = 86,
    EM_V850 = 87,
    EM_M32R = 88,
    EM_MN10300 = 89,
    EM_MN10200 = 90,
    EM_PJ = 91,
    EM_OPENRISC = 92,
    EM_ARC_COMPACT = 93,
    EM_XTENSA = 94,
    EM_VIDEOCORE = 95,
    EM_TMM_GPP = 96,
    EM_NS32K = 97,
    EM_TPC = 98,
    EM_SNP1K = 99,
    EM_ST200 = 100,
    EM_IP2K = 101,
    EM_MAX = 102,
    EM_CR = 103,
    EM_F2MC16 = 104,
    EM_MSP430 = 105,
    EM_BLACKFIN = 106,
    EM_SE_C33 = 107,
    EM_SEP = 108,
    EM_ARCA = 109,
    EM_UNICORE = 110,
    EM_EXCESS = 111,
    EM_DXP = 112,
    EM_ALTERA_NIOS2 = 113,
    EM_CRX = 114,
    EM_XGATE = 115,
    EM_C166 = 116,
    EM_M16C = 117,
    EM_DSPIC30F = 118,
    EM_CE = 119,
    EM_M32C = 120,
    EM_TSK3000 = 131,
    EM_RS08 = 132,
    EM_SHARC = 133,
    EM_ECOG2 = 134,
    EM_SCORE7 = 135,
    EM_DSP24 = 136,
    EM_VIDEOCORE3 = 137,
    EM_LATTICEMICO32 = 138,
    EM_SE_C17 = 139,
    EM_TI_C6000 = 140,
    EM_TI_C2000 = 141,
    EM_TI_C5500 = 142,
    EM_TI_ARP32 = 143,
    EM_TI_PRU = 144,
    EM_MMDSP_PLUS = 160,
    EM_CYPRESS_M8C = 161,
    EM_R32C = 162,
    EM_TRIMEDIA = 163,
    EM_QDSP6 = 164,
    EM_8051 = 165,
    EM_STXP7X = 166,
    EM_NDS32 = 167,
    EM_ECOG1X = 168,
    EM_MAXQ30 = 169,
    EM_XIMO16 = 170,
    EM_MANIK = 171,
    EM_CRAYNV2 = 172,
    EM_RX = 173,
    EM_METAG = 174,
    EM_MCST_ELBRUS = 175,
    EM_ECOG16 = 176,
    EM_CR16 = 177,
    EM_ETPU = 178,
    EM_SLE9X = 179,
    EM_L10M = 180,
    EM_K10M = 181,
    EM_AARCH64 = 183,
    EM_AVR32 = 185,
    EM_STM8 = 186,
    EM_TILE64 = 187,
    EM_TILEPRO = 188,
    EM_MICROBLAZE = 189,
    EM_CUDA = 190,
    EM_TILEGX = 191,
    EM_CLOUDSHIELD = 192,
    EM_COREA_1ST = 193,
    EM_COREA_2ND = 194,
    EM_ARC_COMPACT2 = 195,
    EM_OPEN8 = 196,
    EM_RL78 = 197,
    EM_VIDEOCORE5 = 198,
    EM_78KOR = 199,
    EM_56800EX = 200,
    EM_BA1 = 201,
    EM_BA2 = 202,
    EM_XCORE = 203,
    EM_MCHP_PIC = 204,
    EM_INTEL205 = 205,
    EM_INTEL206 = 206,
    EM_INTEL207 = 207,
    EM_INTEL208 = 208,
    EM_INTEL209 = 209,
    EM_KM32 = 210,
    EM_KMX32 = 211,
    EM_KMX16 = 212,
    EM_KMX8 = 213,
    EM_KVARC = 214,
    EM_CDP = 215,
    EM_COGE = 216,
    EM_COOL = 217,
    EM_NORC = 218,
    EM_CSR_KALIMBA = 219,
    EM_Z80 = 220,
    EM_VISIUM = 221,
    EM_FT32 = 222,
    EM_MOXIE = 223,
    EM_AMDGPU = 224,
    EM_RISCV = 243,
    EM_RESERVED,
}

impl fmt::Display for ElfMachine {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let str = match self {
            ElfMachine::EM_NONE => "No machine",
            ElfMachine::EM_M32 => "AT&T WE 32100",
            ElfMachine::EM_SPARC => "SPARC",
            ElfMachine::EM_386 => "Intel 80386",
            ElfMachine::EM_68K => "Motorola 68000",
            ElfMachine::EM_88K => "Motorola 88000",
            ElfMachine::EM_IAMCU => "Intel MCU",
            ElfMachine::EM_860 => "Intel 80860",
            ElfMachine::EM_MIPS => "MIPS I Architecture",
            ElfMachine::EM_S370 => "IBM System/370 Processor",
            ElfMachine::EM_MIPS_RS3_LE => "MIPS RS3000 Little-endian",
            ElfMachine::EM_PARISC => "Hewlett-Packard PA-RISC",
            ElfMachine::reserved => "Reserved for future use",
            ElfMachine::EM_VPP500 => "Fujitsu VPP500",
            ElfMachine::EM_SPARC32PLUS => "Enhanced instruction set SPARC",
            ElfMachine::EM_960 => "Intel 80960",
            ElfMachine::EM_PPC => "PowerPC",
            ElfMachine::EM_PPC64 => "64-bit PowerPC",
            ElfMachine::EM_S390 => "IBM System/390 Processor",
            ElfMachine::EM_SPU => "IBM SPU/SPC",
            ElfMachine::EM_V800 => "NEC V800",
            ElfMachine::EM_FR20 => "Fujitsu FR20",
            ElfMachine::EM_RH32 => "TRW RH-32",
            ElfMachine::EM_RCE => "Motorola RCE",
            ElfMachine::EM_ARM => "ARM 32-bit architecture (AARCH32)",
            ElfMachine::EM_ALPHA => "Digital Alpha",
            ElfMachine::EM_SH => "Hitachi SH",
            ElfMachine::EM_SPARCV9 => "SPARC Version 9",
            ElfMachine::EM_TRICORE => "Siemens TriCore embedded processor",
            ElfMachine::EM_ARC => "Argonaut RISC Core, Argonaut Technologies Inc.",
            ElfMachine::EM_H8_300 => "Hitachi H8/300",
            ElfMachine::EM_H8_300H => "Hitachi H8/300H",
            ElfMachine::EM_H8S => "Hitachi H8S",
            ElfMachine::EM_H8_500 => "Hitachi H8/500",
            ElfMachine::EM_IA_64 => "Intel IA-64 processor architecture",
            ElfMachine::EM_MIPS_X => "Stanford MIPS-X",
            ElfMachine::EM_COLDFIRE => "Motorola ColdFire",
            ElfMachine::EM_68HC12 => "Motorola M68HC12",
            ElfMachine::EM_MMA => "Fujitsu MMA Multimedia Accelerator",
            ElfMachine::EM_PCP => "Siemens PCP",
            ElfMachine::EM_NCPU => "Sony nCPU embedded RISC processor",
            ElfMachine::EM_NDR1 => "Denso NDR1 microprocessor",
            ElfMachine::EM_STARCORE => "Motorola Star*Core processor",
            ElfMachine::EM_ME16 => "Toyota ME16 processor",
            ElfMachine::EM_ST100 => "STMicroelectronics ST100 processor",
            ElfMachine::EM_TINYJ => "Advanced Logic Corp. TinyJ embedded processor family",
            ElfMachine::EM_X86_64 => "AMD x86-64 architecture",
            ElfMachine::EM_PDSP => "Sony DSP Processor",
            ElfMachine::EM_PDP10 => "Digital Equipment Corp. PDP-10",
            ElfMachine::EM_PDP11 => "Digital Equipment Corp. PDP-11",
            ElfMachine::EM_FX66 => "Siemens FX66 microcontroller",
            ElfMachine::EM_ST9PLUS => "STMicroelectronics ST9+ 8/16 bit microcontroller",
            ElfMachine::EM_ST7 => "STMicroelectronics ST7 8-bit microcontroller",
            ElfMachine::EM_68HC16 => "Motorola MC68HC16 Microcontroller",
            ElfMachine::EM_68HC11 => "Motorola MC68HC11 Microcontroller",
            ElfMachine::EM_68HC08 => "Motorola MC68HC08 Microcontroller",
            ElfMachine::EM_68HC05 => "Motorola MC68HC05 Microcontroller",
            ElfMachine::EM_SVX => "Silicon Graphics SVx",
            ElfMachine::EM_ST19 => "STMicroelectronics ST19 8-bit microcontroller",
            ElfMachine::EM_VAX => "Digital VAX",
            ElfMachine::EM_CRIS => "Axis Communications 32-bit embedded processor",
            ElfMachine::EM_JAVELIN => "Infineon Technologies 32-bit embedded processor",
            ElfMachine::EM_FIREPATH => "Element 14 64-bit DSP Processor",
            ElfMachine::EM_ZSP => "LSI Logic 16-bit DSP Processor",
            ElfMachine::EM_MMIX => "Donald Knuth's educational 64-bit processor",
            ElfMachine::EM_HUANY => "Harvard University machine-independent object files",
            ElfMachine::EM_PRISM => "SiTera Prism",
            ElfMachine::EM_AVR => "Atmel AVR 8-bit microcontroller",
            ElfMachine::EM_FR30 => "Fujitsu FR30",
            ElfMachine::EM_D10V => "Mitsubishi D10V",
            ElfMachine::EM_D30V => "Mitsubishi D30V",
            ElfMachine::EM_V850 => "NEC v850",
            ElfMachine::EM_M32R => "Mitsubishi M32R",
            ElfMachine::EM_MN10300 => "Matsushita MN10300",
            ElfMachine::EM_MN10200 => "Matsushita MN10200",
            ElfMachine::EM_PJ => "picoJava",
            ElfMachine::EM_OPENRISC => "OpenRISC 32-bit embedded processor",
            ElfMachine::EM_ARC_COMPACT => "ARC International ARCompact processor (old spelling/synonym: EM_ARC_A5)",
            ElfMachine::EM_XTENSA => "Tensilica Xtensa Architecture",
            ElfMachine::EM_VIDEOCORE => "Alphamosaic VideoCore processor",
            ElfMachine::EM_TMM_GPP => "Thompson Multimedia General Purpose Processor",
            ElfMachine::EM_NS32K => "National Semiconductor 32000 series",
            ElfMachine::EM_TPC => "Tenor Network TPC processor",
            ElfMachine::EM_SNP1K => "Trebia SNP 1000 processor",
            ElfMachine::EM_ST200 => "STMicroelectronics (www.st.com) ST200 microcontroller",
            ElfMachine::EM_IP2K => "Ubicom IP2xxx microcontroller family",
            ElfMachine::EM_MAX => "MAX Processor",
            ElfMachine::EM_CR => "National Semiconductor CompactRISC microprocessor",
            ElfMachine::EM_F2MC16 => "Fujitsu F2MC16",
            ElfMachine::EM_MSP430 => "Texas Instruments embedded microcontroller msp430",
            ElfMachine::EM_BLACKFIN => "Analog Devices Blackfin (DSP) processor",
            ElfMachine::EM_SE_C33 => "S1C33 Family of Seiko Epson processors",
            ElfMachine::EM_SEP => "Sharp embedded microprocessor",
            ElfMachine::EM_ARCA => "Arca RISC Microprocessor",
            ElfMachine::EM_UNICORE => "Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University",
            ElfMachine::EM_EXCESS => "eXcess: 16/32/64-bit configurable embedded CPU",
            ElfMachine::EM_DXP => "Icera Semiconductor Inc. Deep Execution Processor",
            ElfMachine::EM_ALTERA_NIOS2 => "Altera Nios II soft-core processor",
            ElfMachine::EM_CRX => "National Semiconductor CompactRISC CRX microprocessor",
            ElfMachine::EM_XGATE => "Motorola XGATE embedded processor",
            ElfMachine::EM_C166 => "Infineon C16x/XC16x processor",
            ElfMachine::EM_M16C => "Renesas M16C series microprocessors",
            ElfMachine::EM_DSPIC30F => "Microchip Technology dsPIC30F Digital Signal Controller",
            ElfMachine::EM_CE => "Freescale Communication Engine RISC core",
            ElfMachine::EM_M32C => "Renesas M32C series microprocessors",
            ElfMachine::EM_TSK3000 => "Altium TSK3000 core",
            ElfMachine::EM_RS08 => "Freescale RS08 embedded processor",
            ElfMachine::EM_SHARC => "Analog Devices SHARC family of 32-bit DSP processors",
            ElfMachine::EM_ECOG2 => "Cyan Technology eCOG2 microprocessor",
            ElfMachine::EM_SCORE7 => "Sunplus S+core7 RISC processor",
            ElfMachine::EM_DSP24 => "New Japan Radio (NJR) 24-bit DSP Processor",
            ElfMachine::EM_VIDEOCORE3 => "Broadcom VideoCore III processor",
            ElfMachine::EM_LATTICEMICO32 => "RISC processor for Lattice FPGA architecture",
            ElfMachine::EM_SE_C17 => "Seiko Epson C17 family",
            ElfMachine::EM_TI_C6000 => "The Texas Instruments TMS320C6000 DSP family",
            ElfMachine::EM_TI_C2000 => "The Texas Instruments TMS320C2000 DSP family",
            ElfMachine::EM_TI_C5500 => "The Texas Instruments TMS320C55x DSP family",
            ElfMachine::EM_TI_ARP32 => "Texas Instruments Application Specific RISC Processor, 32bit fetch",
            ElfMachine::EM_TI_PRU => "Texas Instruments Programmable Realtime Unit",
            ElfMachine::EM_MMDSP_PLUS => "STMicroelectronics 64bit VLIW Data Signal Processor",
            ElfMachine::EM_CYPRESS_M8C => "Cypress M8C microprocessor",
            ElfMachine::EM_R32C => "Renesas R32C series microprocessors",
            ElfMachine::EM_TRIMEDIA => "NXP Semiconductors TriMedia architecture family",
            ElfMachine::EM_QDSP6 => "QUALCOMM DSP6 Processor",
            ElfMachine::EM_8051 => "Intel 8051 and variants",
            ElfMachine::EM_STXP7X => "STMicroelectronics STxP7x family of configurable and extensible RISC pr",
            ElfMachine::EM_NDS32 => "Andes Technology compact code size embedded RISC processor family",
            ElfMachine::EM_ECOG1X => "Cyan Technology eCOG1X family",
            ElfMachine::EM_MAXQ30 => "Dallas Semiconductor MAXQ30 Core Micro-controllers",
            ElfMachine::EM_XIMO16 => "New Japan Radio (NJR) 16-bit DSP Processor",
            ElfMachine::EM_MANIK => "M2000 Reconfigurable RISC Microprocessor",
            ElfMachine::EM_CRAYNV2 => "Cray Inc. NV2 vector architecture",
            ElfMachine::EM_RX => "Renesas RX family",
            ElfMachine::EM_METAG => "Imagination Technologies META processor architecture",
            ElfMachine::EM_MCST_ELBRUS => "MCST Elbrus general purpose hardware architecture",
            ElfMachine::EM_ECOG16 => "Cyan Technology eCOG16 family",
            ElfMachine::EM_CR16 => "National Semiconductor CompactRISC CR16 16-bit microprocessor",
            ElfMachine::EM_ETPU => "Freescale Extended Time Processing Unit",
            ElfMachine::EM_SLE9X => "Infineon Technologies SLE9X core",
            ElfMachine::EM_L10M => "Intel L10M",
            ElfMachine::EM_K10M => "Intel K10M",
            ElfMachine::EM_AARCH64 => "ARM 64-bit architecture (AARCH64)",
            ElfMachine::EM_AVR32 => "Atmel Corporation 32-bit microprocessor family",
            ElfMachine::EM_STM8 => "STMicroeletronics STM8 8-bit microcontroller",
            ElfMachine::EM_TILE64 => "Tilera TILE64 multicore architecture family",
            ElfMachine::EM_TILEPRO => "Tilera TILEPro multicore architecture family",
            ElfMachine::EM_MICROBLAZE => "Xilinx MicroBlaze 32-bit RISC soft processor core",
            ElfMachine::EM_CUDA => "NVIDIA CUDA architecture",
            ElfMachine::EM_TILEGX => "Tilera TILE-Gx multicore architecture family",
            ElfMachine::EM_CLOUDSHIELD => "CloudShield architecture family",
            ElfMachine::EM_COREA_1ST => "KIPO-KAIST Core-A 1st generation processor family",
            ElfMachine::EM_COREA_2ND => "KIPO-KAIST Core-A 2nd generation processor family",
            ElfMachine::EM_ARC_COMPACT2 => "Synopsys ARCompact V2",
            ElfMachine::EM_OPEN8 => "Open8 8-bit RISC soft processor core",
            ElfMachine::EM_RL78 => "Renesas RL78 family",
            ElfMachine::EM_VIDEOCORE5 => "Broadcom VideoCore V processor",
            ElfMachine::EM_78KOR => "Renesas 78KOR family",
            ElfMachine::EM_56800EX => "Freescale 56800EX Digital Signal Controller (DSC)",
            ElfMachine::EM_BA1 => "Beyond BA1 CPU architecture",
            ElfMachine::EM_BA2 => "Beyond BA2 CPU architecture",
            ElfMachine::EM_XCORE => "XMOS xCORE processor family",
            ElfMachine::EM_MCHP_PIC => "Microchip 8-bit PIC(r) family",
            ElfMachine::EM_INTEL205 => "Reserved by Intel",
            ElfMachine::EM_INTEL206 => "Reserved by Intel",
            ElfMachine::EM_INTEL207 => "Reserved by Intel",
            ElfMachine::EM_INTEL208 => "Reserved by Intel",
            ElfMachine::EM_INTEL209 => "Reserved by Intel",
            ElfMachine::EM_KM32 => "KM211 KM32 32-bit processor",
            ElfMachine::EM_KMX32 => "KM211 KMX32 32-bit processor",
            ElfMachine::EM_KMX16 => "KM211 KMX16 16-bit processor",
            ElfMachine::EM_KMX8 => "KM211 KMX8 8-bit processor",
            ElfMachine::EM_KVARC => "KM211 KVARC processor",
            ElfMachine::EM_CDP => "Paneve CDP architecture family",
            ElfMachine::EM_COGE => "Cognitive Smart Memory Processor",
            ElfMachine::EM_COOL => "Bluechip Systems CoolEngine",
            ElfMachine::EM_NORC => "Nanoradio Optimized RISC",
            ElfMachine::EM_CSR_KALIMBA => "CSR Kalimba architecture family",
            ElfMachine::EM_Z80 => "Zilog Z80",
            ElfMachine::EM_VISIUM => "Controls and Data Services VISIUMcore processor",
            ElfMachine::EM_FT32 => "FTDI Chip FT32 high performance 32-bit RISC architecture",
            ElfMachine::EM_MOXIE => "Moxie processor family",
            ElfMachine::EM_AMDGPU => "AMD GPU architecture",
            ElfMachine::EM_RISCV => "RISC-V",
            ElfMachine::EM_RESERVED => "Reserved",
        };
        write!(f, "{}", str)
    }
}
